#include <bits/stdc++.h>

using namespace std;

int T, n, m, L, V, d[200001], v[200001],
	a[200001], p[200001], dp[200001], s[200001], mp[1000001];

vector<pair<int, int> > vec, vec1;
vector<int> vec2;

inline int lowbit(int x){
	return x & (-x);
}
void add(int k, int x){
	while(k <= 200000){
		s[k] = min(s[k], x);
		k += lowbit(k);
	}
}
int query(int k){
	int ans = 0x3f3f3f3f;
	while(k >= 1){
		ans = min(ans, s[k]);
		k -= lowbit(k);
	}
	return ans;
}

signed main(){
	freopen("detect.in", "r", stdin);
	freopen("detect.out", "w", stdout);
	scanf("%d", &T);
	while(T--){
		vec.clear(), vec1.clear(), vec2.clear();
		memset(s, 0x3f3f3f3f, sizeof(s));
		memset(mp, 0, sizeof(mp));
		scanf("%d%d%d%d", &n, &m, &L, &V);
		for(int i = 1; i <= n; i++){
			scanf("%d%d%d", d + i, v + i, a + i);
			if(a[i] == 0){
				if(v[i] > V)
					vec.push_back(make_pair(d[i], L));
			}
			else{
				int tmp = abs(V * V - v[i] * v[i]),
					x = tmp / abs(2 * a[i]),
					dt = (tmp % abs(2 * a[i]) == 0);
				if(a[i] > 0 && v[i] > V)
					vec.push_back(make_pair(d[i], L));
				else if(a[i] > 0 && d[i] + x + 1 <= L){
					vec.push_back(make_pair(d[i] + x + 1, L));
				}
				else if(a[i] < 0 && v[i] > V)
					vec.push_back(make_pair(d[i], min(d[i] + x - dt, L)));
			}
		}
		for(int i = 1; i <= m; i++)
			scanf("%d", p + i);
		sort(p + 1, p + m + 1);
		p[m + 1] = 0x3f3f3f3f;
		int maxv = 0;
		for(int i = 0; i < vec.size(); i++){
			int l = vec[i].first, r = vec[i].second;
			if(*lower_bound(p + 1, p + m + 2, l) <= r)
				vec1.push_back(make_pair(l, r)),
				vec2.push_back(r), mp[r] = max(mp[r], l), maxv = max(maxv, l);
		}
		for(int i = 1; i <= L; i++)
			mp[i] = max(mp[i - 1], mp[i]);
		printf("%d ", (int)vec1.size());
		if(vec1.size() == 0){
			printf("%d\n", m);
			continue;
		}
		memset(dp, 0x3f3f3f3f, sizeof(dp));
		dp[0] = 0, add(m + 1, 0);
		p[0] = -1, vec2.push_back(-1);
		sort(vec2.begin(), vec2.end());
		for(int i = 1; i <= m; i++){
			int pos = *(lower_bound(vec2.begin(), vec2.end(), p[i]) - 1),
				pos1 = lower_bound(p, p + m + 1, (pos == -1 ? -1 : mp[pos])) - p;
			dp[i] = min(dp[i], query(m - pos1 + 1) + 1);
			add(m - i + 1, dp[i]);
			if(p[i] >= maxv){
				dp[m] = min(dp[m], dp[i]);
			}
		}
		printf("%d\n", m - dp[m]);
	}
	return 0;
}
